package com.nuoniu.sibanyun.service.project.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nuoniu.sibanyun.entity.project.SysSdtProjectCatalogue;
import com.nuoniu.sibanyun.entity.project.SysSdtProjectFile;
import com.nuoniu.sibanyun.mapper.project.SysSdtProjectFileMapper;
import com.nuoniu.sibanyun.service.project.ISysSdtProjectFileService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 文件管理 服务实现类
 * </p>
 *
 * @author 小啊刚
 * @since 2021-06-05
 */
@Service
public class SysSdtProjectFileServiceImpl extends ServiceImpl<SysSdtProjectFileMapper, SysSdtProjectFile> implements ISysSdtProjectFileService {

    @Override
    public void deleteById(Long id) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("catalogue_id", id);
        remove(wrapper);
    }

    @Override
    public void saveProjectFile(SysSdtProjectFile projectFile) {
        saveOrUpdate(projectFile);
    }

    @Override
    public Page<SysSdtProjectFile> pageList(Page page, SysSdtProjectFile projectFile) {
        QueryWrapper wrapper = new QueryWrapper();
        if(projectFile.getCatalogueId() != null) {
            wrapper.eq("catalogue_id", projectFile.getCatalogueId());
        }

        if(projectFile.getType() != null) {
            wrapper.eq("type", projectFile.getType());
        }
        return page(page, wrapper);
    }
}
